package com.example.demo.javatest;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by liujiahao on 2019/5/13.
 */
public class StringTest {
    public static void main(String[] args) {
        int h;
        System.out.println((h = "ljh".hashCode()) ^ (h >>> 16));
    }

    /**
     * 自实现String trim方法
     */
    public  static  void fun1(){
        String ss="      da   das       ";
        char[] c=ss.toCharArray();
        int str=0;
        int length=c.length;
        while ( (str<length) && (c[str]==' ')){
            str++;
        }
        while ( (str<length) && (c[length-1]==' ')){
            length--;
        }
        System.out.println(ss);
        //System.out.println(ss.replaceAll(" ",""));
        for (int i = 0; i < ss.length(); i++) {
            System.out.println(ss.charAt(i));
        }
    }

    /**
     * == 和 equals
     * 重写了的equals方法比较的是值
     * 未重写和==一样比较的是指向的地址是否一致
     */
    public static void fun2(){
        Integer a=100;
        Integer c=new Integer(100);
        System.out.println(a.equals(c));
        String b="hello";
        System.out.println(b==new String("hello"));
    }
}
